package com.fhz.day013jetpackall;

import com.fhz.day013jetpackall.dao.BannerDao;
import com.fhz.day013jetpackall.entity.Banner;
import com.fhz.day013jetpackall.utils.MyDatabase;

import java.util.List;

import javax.inject.Inject;

/**
 * 时间:2022/5/31
 *
 * @author msfeng
 * 简述: 本地数据源 -> 操作数据库
 */
public class BannerLocalDataSource {

    private MyDatabase myDatabase;
    private BannerDao bannerDao; //new没有了,依赖注入帮我们new了

    public BannerLocalDataSource() {
    }

    //new BannerViewHolder(new BannerRepsitory(new Local(a,b),new Remote()))
    @Inject
    public BannerLocalDataSource(MyDatabase myDatabase, BannerDao bannerDao) {
        this.myDatabase = myDatabase;
        this.bannerDao = bannerDao;
    }

    //插入
    public void insertBanner(Banner... banners){
        bannerDao.insertBanners(banners);
    }

    //查询
    public List<Banner> getBanners(){
       return  bannerDao.getBanners();
    }
}


